﻿using System;
using System.Collections.Generic;
using System.Text;
using NGE;

namespace MH
{
    class Algo
    {
        public static bool MissHit(Character from, Character to)
        {
            int seed1 = Util.Roll(0, 100);
            int seed2 = Util.Roll(0, 100);
            if (seed1 > from.Accurate)
            {
                return true;
            }
            if (seed2 < to.Missrate)
            {
                return true;
            }
            return false;
        }
        public static double Damage(Character from , Character to)
        {
            double dmg = 0;
            int seed1 = 0;
            if (from.Damage > to.Defense)
            {
                dmg = from.Damage - to.Defense;
                if (seed1 < from.Accurate / 10)
                {
                    dmg *= 2;
                }
                else
                {
                    dmg *= (from.Accurate - (double)seed1) / from.Accurate;
                }
            }
            else
            {
                double dmgmax = 0;
                dmgmax = to.Defense / 10;
                dmg = Util.Roll(0, (int)dmgmax);
            }
            return dmg;
        }
    }
}
